//
//  ScVistorTableController.swift
//  weibo03
//
//  Created by mac on 16/9/20.
//  Copyright © 2016年 mac. All rights reserved.
//

import UIKit

class ScVistorTableController: UITableViewController, ScVistorViewDelegate {
    //shif登录的标识
    var islogin: Bool = false
    //方可视图
    var visitorView: ScVistorView?
    //自定义view视图，从写loadView
    override func loadView() {
        if islogin {
            super.loadView()
        }else
        {
            
            //自己提供一个视图
            visitorView = ScVistorView()
            visitorView?.delegate = self
            //visitorView.backgroundColor = UIColor.magenta
            visitorView?.loginClosure = {[weak self] in
                print("我是方可视图闭包调用过来的")
            }
            view = visitorView
            //未登录情况执行添加导航栏按钮
            setupNavUI()
            
        }
    }

    override func viewDidLoad() {
        super.viewDidLoad()
        
    }
    
    private func setupNavUI() {
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "登录", target: self, action: #selector(loginAction))
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "注册", target: self, action: #selector(loginAction))
    }
    
    //mark点击事件
    @objc private func loginAction()
    {
        print("你点击了登录")
    }
    //mark 实现代理方法
    func didSelectedLogin() {
        print("我是方可视图代理对象")
    }

   }
